package com.imot.controller;

import com.imot.pojo.dto.MeasurementDto;
import com.imot.pojo.dto.MonitoringDto;
import com.imot.pojo.dto.NewDeviceDto;
import com.imot.pojo.dto.UpdateMeasurementDto;
import com.imot.response.Result;
import com.imot.service.MonitoringService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: MonitoringController
 * Description:
 * date: 2023/11/18 15:36
 *
 * @author imot-jiah.wang
 */
@Api(tags = "使用监控控制器")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/monitoring")
public class MonitoringController {
    private final MonitoringService monitoringService;

    @ApiOperation("运行监测")
    @PostMapping("/getMethodActivity")
    public Result getMethodActivity(MonitoringDto monitoringDto){
        Result result = monitoringService.evaluateMethodActivity(monitoringDto);
        return result;
    }

    @ApiOperation("新增设备信息")
    @PostMapping("addNewDevice")
    public Result addNewDevice(NewDeviceDto newDeviceDto){
        Result result = monitoringService.addNewDevice(newDeviceDto);
        return result;
    }

    @ApiOperation("查看设备信息")
    @GetMapping("/getDeviceInfo")
    private Result getDeviceInfo(Integer deviceId){
        Result result = monitoringService.getDeviceInfo(deviceId);
        return result;
    }

    @ApiOperation("删除设备")
    @PostMapping("deleteDeviceInfo")
    public Result deleteDeviceInfo(Integer deviceId){
        Result result = monitoringService.deleteDeviceInfo(deviceId);
        return result;
    }

    //---------------------------------------------------------------------------------
    @ApiOperation("获取计量管理")
    @GetMapping("/getMeasurementDetails")
    public Result getMeasurementDetails(@RequestBody MeasurementDto measurementDto){
        Result result = monitoringService.getMeasurementDetails(measurementDto);
        return result;
    }

    @ApiOperation("查看计量详情")
    @GetMapping("/getMeasurementSpecifics")
    public Result getMeasurementSpecifics(Integer id){
        Result result = monitoringService.getMeasurementSpecifics(id);
        return result;
    }

    @ApiOperation("删除计量")
    @DeleteMapping("/deleteMeasurement")
    public Result deleteMeasurement(Integer id){
        Result result = monitoringService.deleteMeasurement(id);
        return result;
    }

    @ApiOperation("编辑计量")
    @PutMapping("/updateMeasurement")
    public Result updateMeasurement(@RequestBody UpdateMeasurementDto updateMeasurementDto){
        Result result = monitoringService.updateMeasurement(updateMeasurementDto);
        return result;
    }
}

